const express = require('express');

// 创建API路由实例
const router = express.Router();

/**
 * API路由配置
 * 各功能模块的路由将在这里挂载
 */

// 导入认证相关中间件
const { authenticateJWT, authorizeAdmin } = require('../../middleware/auth');

// 导入所有路由模块
const authRoutes = require('./authRoutes');
const userRoutes = require('./userRoutes');
const videoRoutes = require('./videoRoutes');
const categoryRoutes = require('./categoryRoutes');
const commentRoutes = require('./commentRoutes');
const likeRoutes = require('./likeRoutes');
const favoriteRoutes = require('./favoriteRoutes');
const messageRoutes = require('./messageRoutes');
const videoTypeRoutes = require('../videoTypeRoutes');
const testRoutes = require('./testRoutes');

// 挂载各模块路由
router.use('/auth', authRoutes);
router.use('/users', userRoutes);
router.use('/videos', videoRoutes);
router.use('/categories', categoryRoutes);
router.use('/comments', commentRoutes);
router.use('/likes', likeRoutes);
router.use('/favorites', favoriteRoutes);
router.use('/messages', messageRoutes);
router.use('/video-types', videoTypeRoutes);
router.use('/test', testRoutes);

// 健康检查接口
router.get('/health', (req, res) => {
  res.json({ status: 'ok', message: '服务运行正常' });
});

// API版本信息路由
router.get('/', (req, res) => {
  res.status(200).json({
    success: true,
    message: 'Harmony API v1',
    endpoints: {
      auth: '/api/v1/auth',
      users: '/api/v1/users',
      videos: '/api/v1/videos',
      videoTypes: '/api/v1/video-types',
      categories: '/api/v1/categories',
      comments: '/api/v1/comments',
      likes: '/api/v1/likes',
      favorites: '/api/v1/favorites',
      messages: '/api/v1/messages'
    }
  });
});

module.exports = router;